package tmt.usercenter.web.configure.security.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.ClientRegistrationException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tmt.usercenter.web.domain.ClientSystem;
import tmt.usercenter.web.domain.security.oauth2.ClientDetailsImpl;
import tmt.usercenter.web.service.ClientSystemService;

import java.util.List;

@Service
@Transactional
public class ClientDetailsServiceImpl implements ClientDetailsService {

    @Autowired
    private ClientSystemService clientSystemService;

    @Override
    public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
        ClientSystem clientSystem = clientSystemService.loadEntity(ClientSystem.class, "findByClientId",
                new Object[]{clientId}, "1");
        return new ClientDetailsImpl(clientSystem);
    }

    public List<ClientDetailsImpl> findClient() {
        return null;
    }
}
